/***************************************************************************
 *   Copyright (C) 2007 by Gokul   *
 *   gokul@linux-7q2y   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#include "CustomLabel.h"

#include <QIcon>
#include <QStringList>

#include <QHBoxLayout>
#include <QWheelEvent>

CustomLabel::CustomLabel(QWidget *parent)
 : QWidget(parent)
{

    QHBoxLayout *horizontalLayout = new QHBoxLayout(this);
    
    label = new QLabel(this);
    
	 horizontalLayout->setMargin(0);
     horizontalLayout->addWidget(label);

		//qDebug("Random = %d",random);
	//img = new QImage(list.at(random));

	//QImage tempImg = scale(*img,80);


	//this->pixmap()->scaled(QSize(50,50));	
	resize(80,80);

	//this->setSize(80,80);
 //    this->setEnabled(true);
//     this->setAlignment(Qt::AlignCenter);
//     this->setFrameShape(QFrame::Box);
//     this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
     //this->setBackgroundRole(QPalette::Base);
   //  this->setAutoFillBackground(true);
     //this->setMinimumSize(132, 132);
//	this->setWindowFlags(Qt::Window);
}


CustomLabel::~CustomLabel()
{

}

void CustomLabel::setImage(QImage image)
{
	if(image.isNull())
	{
		qDebug("Image is nulll \n");
	}
	img = image;
	//QBrush brush(image);
	//QPalette palette;
	//palette.setBrush(QPalette::Background,brush);
	//this->setPalette(palette);
	label->setPixmap(QPixmap::fromImage(image));
	update();
}


void CustomLabel::wheelEvent(QWheelEvent *e)
{
	int numDegrees = e->delta() / 8;

	if ( numDegrees<0 )
	{
		this->resize(width() + 80,height() + 80);
	}
	else
	{
		this->resize(width() - 80,height() - 80);
	}

	update();     	

}
